'** Eddie - an LB Code Editor
[WindowSetup]
NOMAINWIN
WindowWidth = 692 : WindowHeight = 413
UpperLeftX = INT((DisplayWidth-WindowWidth)/2)
UpperLeftY = INT((DisplayHeight-WindowHeight)/2)
[ControlSetup]
'menus
Menu #1, "&File", "&New", [new], "&Open", [open], "&Save", [save],_
|,"&Print", [print], "E&xit", [quit]
'LB will place Edit menu where you specify in list of menus
'do not use ampersand & in Edit menu caption
Menu #1, "Edit"
Menu #1, "&Run","R&un", [run]
Menu #1, "&Help", "He&lp", [help], "&About", [about]
'buttons for a toolbar lookalike
button #1.new, "New",[new],UL, 0, 0, 45, 20
button #1.open, "Open",[open],UL, 45, 0, 45, 20
button #1.save, "Save",[save],UL, 90, 0, 45, 20
button #1.print, "Print",[print],UL, 135, 0, 45, 20
button #1.cut, "Cut",[cut],UL, 190, 0, 45, 20
button #1.copy, "Copy",[copy],UL, 235, 0, 45, 20
button #1.paste, "Paste",[paste],UL, 280, 0, 45, 20
button #1.run, "Run",[run],UL, 335, 0, 45, 20
button #1.help, "Help",[help],UL, 380, 0, 45, 20
'a texteditor
texteditor #1.te, 2, 22, 680, 335
Open "Eddie - an LB Code Editor" for Window as #1
'trap the close event, if the user closes the
'window with the X button
#1 "trapclose [quit]"
'set the font for the window and controls
#1 "font ms_sans_serif 10"
'set a custom font for the texteditor
#1.te "!font courier_new 10"
'cause the texteditor to resize automatically
'when the user resizes the window
#1.te "!autoresize"
[loop]
Wait
[quit]
close #1 : END
[new]
#1.te "!CLS"
Wait
[open]
filedialog "Open","*.bas",openfile$
if openfile$="" then wait
open openfile$ for input as #f
'dump contents of file into texteditor
#1.te "!contents #f"
close #f
Wait
[save]
'if the word SAVE is in the caption, LB
'automatically creates a SAVE dialog
filedialog "Save As","*.bas",savefile$
if savefile$="" then wait
'make sure that user had given the file a *bas extension
if right$(lower$(savefile$),4)<>".bas" then
savefile$=savefile$+".bas"
end if
'get contents of texteditor into string variable
#1.te "!contents? text$"
if text$="" then
notice "No file to save."
wait
end if
'open file and write text to it
open savefile$ for output as #f
#f text$
close #f
Wait
[print]
'get contents of texteditor into string variable
#1.te "!contents? text$"
if text$="" then
notice "No text to print."
wait
end if
'send text to printer
lprint text$
'cause printing to happen now
dump
Wait
[help]
'place code here
Wait
[about]
'place code here
Wait
[cut]
#1.te "!cut"
wait
[copy]
#1.te "!copy"
wait
[paste]
#1.te "!paste"
wait
[run]
'place code here
wait